//
//  GKZYUniversityListCell.m
//  GKZYAid
//
//  Created by Tony Zhang on 16/3/11.
//  Copyright © 2016年 GKZYAid. All rights reserved.
//

#import "GKZYUniversityListCell.h"
#import "MyDefine.h"
#import <UIImageView+WebCache.h>

@implementation GKZYUniversityListCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
     
    }
    return self;
}


-(void)configureTheCellWithModel:(GKZYUniversityQueryModel *)model{

    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(5, 5, KmainScreenBoundsWidth-10, 110)];
    view.backgroundColor = [UIColor whiteColor];
    [self addSubview:view];
    
    UIImageView *image = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, 40, 40)];
    [image sd_setImageWithURL:[NSURL URLWithString:model.sch_logo]];
    [view addSubview:image];
    
    UILabel *nameLab = [[UILabel alloc]init];
    CGSize size1 = [model.sch_name sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:nameLab.font,NSFontAttributeName, nil]];
    nameLab.frame = CGRectMake(CGRectGetMaxX(image.frame)+10, 5, size1.width, 30);
    nameLab.text = model.sch_name;
    [view addSubview:nameLab];
    
    UILabel *locationLab = [[UILabel alloc]init];
    locationLab.frame = CGRectMake(CGRectGetMaxX(nameLab.frame)+20, 12, 80, 20);
    locationLab.text = model.sch_loc;
    locationLab.font = [UIFont systemFontOfSize:12];
    locationLab.textColor = [UIColor lightGrayColor];
    [view addSubview:locationLab];
    NSString *string = nil;
    if ([model.toudang_year floatValue] == -1.0) {
       string = @"-年录取平均分";
    }else{
       string = @"2014年录取平均分:";
    }
    UILabel *yearLab = [[UILabel alloc]init];
    yearLab.font = [UIFont systemFontOfSize:12];
    CGSize size2 = [string sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:yearLab.font,NSFontAttributeName, nil]];
    yearLab.frame = CGRectMake(CGRectGetMaxX(image.frame)+10, 35, size2.width, 30);
    yearLab.text = string;
    [view addSubview:yearLab];
    
    UILabel *scrolLab = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(yearLab.frame)+2, 35, 40, 30)];
    scrolLab.textColor = [UIColor orangeColor];
    scrolLab.text = [NSString stringWithFormat:@"%@",model.toudang_score];
    [view addSubview:scrolLab];
    
    UILabel *ratioTitle = [[UILabel alloc]init];
    ratioTitle.text = @"录取概率:";
    ratioTitle.font = [UIFont systemFontOfSize:12];
    CGSize size3 = [ratioTitle.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:ratioTitle.font,NSFontAttributeName, nil]];
    ratioTitle.frame = CGRectMake(KmainScreenBoundsWidth-60-size3.width, 35, size3.width, 30);
    [view addSubview:ratioTitle];
    
    UILabel *ratioLab = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(ratioTitle.frame)+2, 35, 45, 30)];
    NSString *str = nil;
    if ([model.safe_ratio floatValue] == -1.0) {
       str = @"-";
    }else{
    str = [NSString stringWithFormat:@"%.0f",[model.safe_ratio floatValue]*100 ];
    }
    ratioLab.text = [str stringByAppendingString:@"%"];
    ratioLab.textColor = [UIColor orangeColor];
    [view addSubview:ratioLab];
    
    UILabel *index = [[UILabel alloc]init];
    NSString *indexStr = @"学校综合排名:";
    index.font = [UIFont systemFontOfSize:12];
    index.textColor = [UIColor grayColor];
    CGSize size4 = [indexStr sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:index.font,NSFontAttributeName, nil]];
    index.text =indexStr;
    index.frame = CGRectMake(CGRectGetMaxX(image.frame)+10, 65, size4.width, 30);
    [view addSubview:index];
    
    UILabel *indexLab = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(index.frame)+2, 65, 40, 30)];
    indexLab.textColor = [UIColor orangeColor];
    indexLab.text = [NSString stringWithFormat:@"%ld",(long)[model.sch_rank_index integerValue]];
    [view addSubview:indexLab];
    
    UILabel *salary = [[UILabel alloc]init];
    NSString *salaryStr = @"学府类型:";
    salary.font = [UIFont systemFontOfSize:12];
    CGSize size5 = [salaryStr sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:salary.font,NSFontAttributeName, nil]];
    salary.frame = CGRectMake(KmainScreenBoundsWidth - size5.width-70, 65, size5.width, 30);
    salary.text = salaryStr;
    [view addSubview:salary];
    
    UILabel *type = [[UILabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(salary.frame)+2, 65, 50,30)];
    type.text = model.sch_type;
    type.font = [UIFont systemFontOfSize:14];
    type.textColor = [UIColor orangeColor];
    [view addSubview:type];
    
}



@end
